Skip to content

Conversation

manerlan
Copy link
Member

Fixed the issue by preserving the user's last submitted search in sessionStorage. Only search term is put in sessionStorage, not PokéAPI response. TanStack Query is still responsible for the server data, whilst sessionStorage handles the UI state needed.

Changes:

  • Saves the submitted search query in sessionStorage.
  • Restores the search field when returning to the application.
  • Recreates the search results from the Pokémon data managed by TanStack Query.
  • Preserves the existing empty-search and no-results messages.
  • Avoids storing API data in sessionStorage.

This has been tested:

  • Successfull run of npm run lint and npm run build
  • Manual testing of search function
  • Verified that search field and results remain after clicking onto a Pokémon and navigating back.
  • Tested empty searches and searches with no results.

@manerlan manerlan requested a review from a team as a code owner September 17, 2026 12:37
Copy link
Member

@siverne siverne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good. Walked through with @manerlan

@oscarba
Copy link
Member

oscarba commented Sep 17, 2026

Burde ikke recent searches komme ned i en drop down meny eller noe sånt, når du klikker på search baren?

@oscarba oscarba merged commit 28bfe54 into main Sep 17, 2026
@oscarba oscarba deleted the 17-search-results-should-stay-loaded branch September 17, 2026 13:27
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search results should stay loaded when clicking previous after clicking on a Pokémon
3 participants